From: Robert Lipe Date: Wed, 18 Nov 2015 23:24:37 +0000 (-0600) Subject: Add a check in unicsv to error if both -t and -r are set or if either are used with... X-Git-Tag: archive/raspbian/1.10.0+ds-2+rpi1~1^2~12^2~10^2~12 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=eea56c4491b54910d3d1da56b8c3f1140df6efda;p=gpsbabel.git Add a check in unicsv to error if both -t and -r are set or if either are used with -w, the default. --- diff --git a/unicsv.cc b/unicsv.cc index 56a426f70..6a2830ca0 100644 --- a/unicsv.cc +++ b/unicsv.cc @@ -26,6 +26,7 @@ #include "garmin_fs.h" #include "garmin_tables.h" #include "jeeps/gpsmath.h" +#include "src/core/logging.h" #include #include @@ -348,7 +349,7 @@ unicsv_parse_date(const char* str, int* consumed) *consumed = 0; /* for a possible date */ return 0; } - fatal(MYNAME ": Could not parse date string (%s).\n", str); + Fatal() << MYNAME << ": Could not parse date string (" << str << ").\n"; } if ((p1 > 99) || (sep[0] == '-')) { /* Y-M-D (iso like) */ @@ -377,7 +378,7 @@ unicsv_parse_date(const char* str, int* consumed) *consumed = 0; return 0; /* don't stop here */ } - fatal(MYNAME ": Could not parse date string (%s).\n", str); + Fatal() << MYNAME << ": Could not parse date string (" << str << ").\n"; } tm.tm_year -= 1900; @@ -1878,22 +1879,39 @@ unicsv_wr_deinit(void) gbfclose(fout); } +// Waypoints are default-on and there's no way to turn them off. This is +// used to see if a user specified (-t OR -r) in addition to the default +// of -w. It's pretty weak, but it's better than letting the last flag +// 'win' which can result in no data silently being displayed. + +static void +unicsv_check_modes(bool test) { + if (test) { + Fatal() << MYNAME << + " : Invalid combination of -w, -t, -r selected. Use only one."; + } +} + + static void unicsv_wr(void) { switch (global_opts.objective) { case wptdata: case unknown_gpsdata: + unicsv_check_modes (doing_rtes || doing_trks); waypt_disp_all(unicsv_waypt_enum_cb); break; case trkdata: + unicsv_check_modes (doing_rtes); track_disp_all(NULL, NULL, unicsv_waypt_enum_cb); break; case rtedata: + unicsv_check_modes (doing_trks); route_disp_all(NULL, NULL, unicsv_waypt_enum_cb); break; case posndata: - fatal(MYNAME ": Realtime positioning not supported.\n"); + Fatal() << MYNAME << ": Realtime positioning not supported."; } gbfprintf(fout, "No%s", unicsv_fieldsep);